package rtlmmap

type View struct {
	fs  uint64
	inf Interface
}

func (self *View) Raw(start, fl int) []complex128 {
	s := uint64(int64(start)*int64(self.inf.FrameLength()) + int64(self.fs))
	l := int64(fl) * int64(self.inf.FrameLength())
	// log.Info("Raw:", s, l, "start", self.fs, self.Now())
	return self.inf.GetIQ(s, l)
}

func (self *View) Now() uint64 { return self.inf.Now() }
func (self *View) HardReset() {
	self.fs = self.inf.GetNearest(true)
	self.Run(10)
}

func (self *View) Reset() {
	self.fs = self.inf.GetNearest(false)
	self.Run(10)
}

func (self *View) Run(fl int) {
	self.fs = uint64(int64(fl)*int64(self.inf.FrameLength()) + int64(self.fs))
}

func NewRtlView(idx int, sys SystemConfig) *View {
	ftco := NewFTco(idx, sys, RtlInt8{})
	return &View{ftco.FrameStart(), ftco}
}

func (self *View) GetFTco() *FTco {
	return self.inf.(*FTco)
}
